package values.enlist
{
	public class EnlistNumTemplateValue
	{
		[Data(type="field" , mapping="@level_start")]
		public var levelStart:int;
		
		private var _levelEnd:int;

		
		public function get levelEnd():int
		{
			return _levelEnd;
		}
		
		[Data(type="field" , mapping="@level_end")]
		public function set levelEnd(value:int):void
		{
			if(value == -1) value = int.MAX_VALUE
			_levelEnd = value;
		}

		
		[Data(type="field" , mapping="@unit_level")]
		public var unitLevel:int;
		
		[Data(type="field" , mapping="@unit_num")]
		public var unitNum:int;
		
		public function isInThisLevel(value:int):Boolean
		{
			return (value >= levelStart && value <= levelEnd);
		}
		
		public function getLevelInThisPart(value:int):int
		{
			return Math.floor( (value - levelStart + 1) / unitLevel) * unitNum;
		}
		
		private var _allNum:int = -1;
		
		public function getAllNum():int
		{
			if(_allNum == -1)
			{
				_allNum = Math.floor( ( levelEnd - levelStart + 1) / unitLevel ) * unitNum;
			}
			
			return _allNum;
		}
	}
}